Modified calculateAngle