fixed compiler for loop bug