error with for loop