replaced "in" for loops with "classic" for loops