Refactored shell scripts