Refactored the build script