fixed some bugs stemming from a misinterpretation of the pdf