# If else statement inside a step of algorithm

I am trying to write if-else loop in an algorithm within the substeps. Somehow it doesn't appear as expected.

\documentclass[]{article}

\usepackage{algorithm,algpseudocode,float}
\usepackage{graphicx}
\usepackage{amsmath,paralist}
\usepackage{color,listings}
\input{listings-modelica.cfg}
\lstset{language = Modelica,
basicstyle=\fontsize{9pt}{10.5pt}\selectfont,
backgroundcolor = \color{white},
aboveskip = 0pt,
belowskip = 0pt}

\makeatletter
\newenvironment{breakablealgorithm}
{% \begin{breakablealgorithm}
\begin{center}
\refstepcounter{algorithm}% New algorithm
\hrule height.8pt depth0pt \kern2pt% \@fs@pre for \@fs@ruled
\renewcommand{\caption}[2][\relax]{% Make a new \caption
{\raggedright\textbf{\ALG@name~\thealgorithm} ##2\par}%
\ifx\relax##1\relax % #1 is \relax
\else % #1 is not \relax
\fi
\kern2pt\hrule\kern2pt
}
}{% \end{breakablealgorithm}
\kern2pt\hrule\relax% \@fs@post for \@fs@ruled
\end{center}
}
\makeatother

\newcounter{algsubstate}
\renewcommand{\thealgsubstate}{\alph{algsubstate}}
\newenvironment{algsubstates}
{\setcounter{algsubstate}{0}%
\renewcommand{\State}{%
\stepcounter{algsubstate}%
\Statex {\footnotesize\thealgsubstate:}\space}}
{}

\newcommand{\algoref}[1]{Algorithm~\ref{#1}}
\newcommand{\comment}{\newline \Comment}

\begin{document}
\begin{algorithm}
\caption{Equations in a material stream}
\begin{algorithmic}[1]

\State Overall Material Balance
$$F = L + V$$

\State Component wise Material Balance
$$z_i F = x_i L + y_i V$$

\State Equilibrium equation:
$$y_i = K_i x_i$$

\State Vapor Phase Mole Fraction:
$$\beta = \frac{V}{F}$$

\State Summation equaton:
$$\sum_{i=1}^n y_i = 1$$

$$\sum_{i=1}^n x_i = 1$$

\State Phase mole fraction
\begin{algsubstates}
\State
\If{$P \geq P_{bubble}$}
$$x_i = z_i$$
$$y_i = 0$$
\State
\ElsIf {$P \geq P_{bubble}$}
$$x_i = \frac{L_i}{F_i}$$
$$y_i = \frac{V_i}{F_i}$$
\State
\Else
$$y_i = z_i$$
$$x_i = 0$$
\EndIf
\end{algsubstates}
\end{algorithmic}
\end{algorithm}

\end{document}


In the image, what appears at step 7 should appear at point a, what appears at step 8 should appear at point b and what appears at step 9 should appear at point c.