Refactored output formatting