Adding more error checking to shell script