updated shell script to work in bin/sh