refactoring and map fix