additions, changes and refactoring for report generation