In the Black and Scholes model, when it is needed to immunize the portfolio from variations in the stock the argument given is the following. If $\alpha_t$ is the amount of invested in the stock, $\beta_t$ the amount in the bond, we construct a portfolio whose value is
$$ V_t = -C_t+\alpha_t\,S_t+\beta_t\,B_t, $$
where $C_t=f\left(t,S_t\right)$ is the price of a Call option and where $S_t$ and $B_t$ are, respectively, the price of the stock and the price of the bond at time $t$. So we are short selling one unit of the call and buying the portfolio whose $\alpha_t\,S_t+\beta_t\,B_t$. Now one chooses $x$ such that
$$ \frac{\partial V_t}{\partial S_t} = 0\Leftrightarrow -\frac{\partial C_t}{\partial S_t}+\alpha_t=0\Leftrightarrow \alpha_t = \frac{\partial C_t}{\partial S_t}\equiv \Delta_t. $$
What puzzles me is the fact that when deriving the value of the portfolio we assume that $\alpha_t$ does not depend from $S_t$ whereas the final solution does depend. So in principle one should do this computation (assuming that $\beta_t$ does not depend on $S_t$)
$$ \frac{\partial V_t}{\partial S_t} = -\frac{\partial C_t}{\partial S_t}+\alpha_t+\frac{\partial \alpha_t}{\partial S_t}\,S_t = 0 $$
whose solution is of course different from $\alpha_t=\Delta_t$. Where am I wrong?