improved iterating over hashmap