Refactored report code