I want to show that $\forall x$,$y\in G$, $(xy)^2=x^2y^2 \iff G $ is an abelian group.
Proof of the backward direction seems easy enough:
Assume $G$ is an abelian group. Then consider $(xy)^2=(xy)(xy)$. By associativity, $(xy)(xy)=xyxy$. Since $G$ is abelian, $xyxy=xxyy=x^2y^2$.
Proof of the forward direction I attempt by contrapositive:
That is, assume $G$ is not an abelian group. Then, consider $(xy)^2=xyxy$ as above. Yet, $xyxy\neq xxyy=x^2y^2$ since we no longer have commutativity.
Is this proof by contrapositive completely correct?