Redefine loop counter at each for, to avoid scope issues