while loop adjusted