Rotation smoothing vive tracker

Need some help with some rotation maths.
I am trying to add some smoothing to a vive tracker but due to the fact that an axis goes from -negative to positive degrees my results when the angle crosses 0 either way causes strange behaviour. i understand why of course and that is because if you have 9 values each of 179 an then you rotate the tracker by a couple of degrees and get -179 it really screw the average value.

My maths sucks at best and wondered if anyone knew the correct way to solve this.
I may be tackling it from the wrong angle and there may well be a much better way to do this.

My blueprint is sprawling so I have uploaded it to the link below it may be useful to someone else.
View Blueprint

Tried adding 360 if the returned value is less than 0 and that doesn’t seem to remove the problem