build script refactored