Implemented isValidMove