restructuring JS code to display new reports