*** code reordered
*** added pphfunctions