changed to for loop