restructured base.js