Error handling added to shell script