started refactoring map.js