Refactor build.sh