refactoring map class