refine shell script