Fixed for loop error