Updated loop to iterate over the "entrySet" instead of the "keySet".