avoid shadowing of outer loop variable, use preincrement in inner loop