refactored shell scripts