Improved the bash scripting