update for loops to be jsLint friendly and correct