Refactored code for new Report function.