Refactored pdf_helper, made code much more DRY