shell script optimization