i needs to be declared and initialized in the for loop