rephrased while loop