Angle calculation deviation issue

Hi Everyone, I am wrote this function to calculate the angle between vectors that ranges from 0-360. But for some reason, when the target vectors angle is more than 90 degrees the output shows angle value around 270 degrees.
Any Idea why this happening?

003_Calculate (13.7 KB)

To avoid confusion use always a reference (i.e. a plane Z vect) for Vector3d.VectorAngle. See attached (and the Maths C#) (120.4 KB)

Thanks for the input @PeterFotiadis . It helped a lot.