add more exit status checks
move `fetch` function to `common.sh`