added functions (claculatePD(), P(), D())
filled out functions