fixed up shell script bugs