Prove that G is abelian if and only if the map $\displaystyle f: G \longrightarrow G$ given by $\displaystyle f(g)=g^2$ is a group homomorphism.

$\displaystyle f(g_{1} \cdot g_{2})=g_{1}g_{2}g_{1}g_{2}=g_{1}g_{1}g_{2}g_{2}=g _{1}^2g_{2}^2$

if G abelian then f is homomorphism.

Nevertheless i prove only one direction of the statement. Can anybody help me?