Let's consider a track that begins vertically becomes a 450 degree loop, and level off. (See diagram) enter image description here

We drop a block from height $H$ that falls and goes around the loop. Ignoring air resistance, but taking into account a friction coefficient of $\mu$ against the track, find the smallest $H$ for which the block will complete the loop.

By conservation of energy I have obtained the following equation:

$$ mgH = \frac{m v(\theta)^2}{2}+mgR(1+\mu-\sin(\theta)) + m\mu R \int_0^\theta\left( g \sin(\theta) + \frac{v(\theta)^2}{R}\right) d\theta $$

Where $v(\theta)$ the the block's speed at $\theta$, and $\theta$ is an angle measured between the block's position (centred at loop center) and a horizontal line going left-wards.

The left hand side is gravitational potential energy, the first term on the right is kinetic energy, the next one is also gravitational potential energy, and the last one - the work done by friction.

Dividing by $m$, differentiating with respect to $\theta$, and using the chain rule on the first term on the right hand side we obtain:

$$ 0=v(\theta)\frac{dv(\theta)}{d\theta} +gR(\mu\sin(\theta) -cos(\theta)) + \mu v(\theta)^2$$

Assuming the block doesn't make it, because it lost's its speed to friction, let's find $\theta$ for which $V(\theta) = 0$. Substituting we get:

$$ 0 = \mu \sin(\theta) - \cos(\theta) $$

But it is totally counter intuitive (and incorrect by experiment), that this point depends only on $\mu$ and not on the initial height $H$. So where did I make the mistake? Could somebody please clarify.