refactor base.js