changed to while