Small refactor to map.js