Fixed js arrays to be compatible with for loops in code