changes to calculate phase angle properly