code for report generation