Fixed if to while