Refactor map.js
Finish refactor