refactored old build script