(refactor) rafactor map.js and add comments