Refactored the the build script