fixed bug in new PHI code