refactored terminal