Variables for spatial and spin symmetry added. isValid function is updated to reflect symmetry