refactor read_pdf method