adding phase calculation