Why is this function on the Riemann surface holomorphic?

Forster defines analytic continuation of a germ of a holomorphic function at a point on a Riemann surface as follows.

Suppose $X$ is a Riemann surface, $a\in X$ and $\phi\in\mathcal{O}_a$ is a function germ. The quadrupel $(Y,p,f,b)$ is called an analytic continuation of $\phi$ if:

a) $Y$ is a riemann surface and $p:Y\longrightarrow X$ is an unbranched holomorphic map.

b)$f$ is a homolomprhic function on $Y$.

c) $b$ is a point of $Y$ such that $p(b)=a$ and $p_*(\rho_b(f))=\phi$, where $\rho_b(f)$ is the germ of $f$ at $b$ as an element of $\mathcal{O}_b$. Here $p_*:\mathcal{O}_{Y,y}\longrightarrow \mathcal{O}_{X,p(y)}$ is the inverse to the natural isomorphism $\mathcal{O}_{X,p(y)}\longrightarrow\mathcal{O}_{Y,y}$.

He later proves the following : if $X$ is a Riemann surface, $a\in X$ and $\phi\in\mathcal{O}_a$, then there exists a maximal analytic continuation $(Y,p,f,b)$ of $\phi$.

I have a doubt in the proof which goes as follows:

Let $Y$ be the connected component of $|O| = \amalg\mathcal{O}_p$ (with the natural topology) which contains $\phi$. And $p$ be the restriction of the projection map $|\mathcal{O}|\longrightarrow X$ to $Y$. Then we know by previous results that $p$ is a local homemorphism, and that we can give a Riemann surface structure on $Y$ such that $p$ becomes holomorphic.

Now we define a holomorphic function $f:Y\longrightarrow\mathbb{C}$ as follows : By definition, every $\sigma\in Y$ is a function germ at the point $p(\sigma)\in X$. Set $f(\sigma)=\sigma(p(\sigma))$ for all $\sigma\in Y$.

My question is why is this function $f$ holomorphic? Any help will be appreciated!

I will follow Forster's notaion. It suffices to show that the restriction $f|[U,g]$ is holomorphic for every $g\in\mathcal{O}(U)$. Without loss of generality, we may assume that $(U,\varphi)$ is a chart. Since $p|[U,g]\colon[U,g]\to U$ is a homeomorphism, $([U,g],\varphi\circ p|[U,g])$ is a chart on $|\mathcal{O}|$. It follows that \begin{align} f(\varphi\circ p|[U,g])^{-1}(z) &=f(p|[U,g])^{-1}\varphi^{-1}(z)\\ &=f(\rho_{\varphi^{-1}(z)}(g))\\ &=\rho_{\varphi^{-1}(z)}(g)(\varphi^{-1}(z))\\ &=g\varphi^{-1}(z) \end{align} for every $z\in\varphi(U)$. Hence, $f$ is holomorphic in $[U,g]$.