move path check outside of download_pdf method