working on map and some light refactoring