for loop to while