first working version for getting the pdf work