Improved the PDF Output Algorithm