minor revision with var added in for loops