nested for loop error