fixed the for loop