refactor shell script