map refactoring and optimization