refactored the reporting script