Refactor build.js