output refactoring