Moved code back into report.php from report_helper