refactoring bash commands