Outer for loop already uses iIndex. JS seems to stumble on this double use of the same variable name.