build script refactor