updated to discern between pdfs and pngs