Fix logical operator of while loop