refactor of build script