refactor build script.