map js refactoring