added phi_d calculation