refactor the map.js file