Change to while loop