refactoring to a map-centric approach