refactor build script