Refactored getMap method