Let $G$ be a $p$-group of order $p^{4}$ and exponent $p$. I want to prove that if $G$ has no nontrivial direct factors then it is of maximal class.
My try: Let $H$ be a proper nonabelian subgroup of $G$, then $|H|=p^{3}$. Now, let $x\in C_G(H)$. If $x\notin H$ then $G=\langle x\rangle\cdot H$, a contradiction. So, $C_{G}(H)<H$.
Did I miss something? Thank you in advance.