Refactor map js