Update build.sh

Tidy up code - Needs testing