Functiorality of the affine variety-affine ring equivalence Following Hartshorne I.4., one associates to a morphism $\varphi : X \rightarrow Y$ of affine $k$-varieties a morphism $h_{\varphi} : A(Y) \rightarrow A(X)$ of $k$-algebras, and reciprocally to a morphism $h : A(Y) \rightarrow A(X)$ of $k$-algebras a morphism $\varphi_{h} : X \rightarrow Y$ of affine $k$-varieties. The maps $h \mapsto \varphi_{h}$ and $\varphi \mapsto h_{\varphi}$ are reciprocals of one another and one can show that they are functorial (i.e. $\varphi_{g \circ h} = \varphi_g \circ \varphi_h$, etc.). This last fact is obvious when it comes to $\varphi \mapsto h_{\varphi}$ and is then true of its reciprocal $h \mapsto \varphi_{h}$. But is there a way of proving it directly? Thanks.
 A: The goal is to show that if we have two morphisms of affine $k$-algebras $h:A(Z)\to A(Y)$ and $g:A(Y)\to A(X)$, then the induced maps $\varphi_{g\circ h}:X\to Z$, $\varphi_{g}:X\to Y$ and $\varphi_h:Y\to Z$ satisfy $\varphi_{g\circ h} = \varphi_g\circ\varphi_h$. 
The key idea here is that the points of an affine variety are in canonical bijection with the maximal ideals of it's coordinate ring. From here, we can see that if $f:X\to Y$ is a morphism of affine $k$-varieties sending $x\to y$, we get that the associated map on coordinate algebras $f^\sharp: A(Y)\to A(X)$ satisfies $(f^\sharp)^{-1}(\mathfrak{m}_x) \subset \mathfrak{m}_y$, and then as the preimage of a maximal ideal is maximal for a morphism of reduced fg algebras over a field, this must actually be an equality. So by describing $\varphi_{g\circ h}(x)$ as the point associated to $(g\circ h)^{-1}(\mathfrak{m}_x)$ versus $\varphi_g\circ\varphi_h(x)$ as the point associated to $h^{-1}(g^{-1}(\mathfrak{m}_x))$, we see that these are the same point, and thus the maps of affine varieties are the same.
