Map code refactoring