terminal refactoring