refractored some of the reporting code