Modify function selectSquare to catch illegal movement of piece.