Refactor bootstrap.sh to use functions