Added comments for clarification and replaced concrete parameter type with interface

Replaced HashMap with Map