solution to isSymmetric