changed the for loop from the incorrect for..in statement to a regular for statement