Improved the shell script