Changed from keySet() to entrySet() iterators