refactored pdf properly