Refactoring for cleaner data output