switched back from while loop sto for loop