rewrote much of update.sh