made the loop variable local, since it was hosing external uses of i variable.