Minor edits
Added a separate function for catching the ERR signal that aborts the
script when called.