fixed bug in calculation of Psi