checks for valid moves