move pdf to the end so pdf isnt created when the script fails early on