output refactor