checking for exit status messy
checking exit status of parts of script
using functions