Refactored print preview data query