Changed condition in while loop in Boolean Function