added calculcate_pXCi function