refactored report generation