I have following pseudocode:

I want to write it as an algorithm but not able to format it properly. Following is my attempt:
\documentclass{article}
\usepackage{algorithm,amsmath,algpseudocode}
\begin{document}
\begin{algorithm}
\caption{Adaptive Thresholding}\label{euclid}
\begin{algorithmic}[1]
\State Convert $R$ to a binary region using the threshold $\theta_{0}$. \label{step:convert}
\State Assume $N$ is the sum of the number of non-zero pixels within $F_{l}$ and $F_{r}$.
\State If $N$ is larger than a predefined threshold $\beta$, then
\State $\theta_{0} = \theta_{0} + \Delta\theta$
\State Repeat the procedure from step \ref{step:convert}
\State Else
\State $\theta = \theta_{0}$
\State End
\State where $\Delta\theta$, $\beta$ are two constants.
\end{algorithmic}
\end{algorithm}
\end{document}
and this is what I get:

Any ideas how to format lines 4-8? I have to show the pseudocode in algorithm format.
If Then Elseis properly defined as:\IF{condition 1}\STATE procedure 1\ELSIF{condition 2}\STATE procedure 2\ELSIF{condition 3}\STATE procedure 3\ELSE\STATE procedure 4\ENDIF– pluton Nov 08 '14 at 19:57