added Phase 4 in src/map_refactor.js