refactoring: format data as it goes