refactoring output in preparation for format flags