improved shell script