changed the for loop to a hash table