changed for to while