refactor map js