made build.sh a little more intelligent