Changed iterating over array with for ... in to a for loop