Rotation Angle across 0, opposing angle?

Hi I ve got a tower that rotates towards a target. I am using a helper object that looks at the target and then i am lerping from the current rotation to the helper objects rotation. the problem that i have atm is when the target passes infront of my tower it rotates all the way around, so instead of going from +5 to -5 degrees (i want it to rotate 10 degrees) it rotates 350 degrees.
what am i missing? here is a bit of my aiming code:

	    endBaseAngle = rotateHelper.transform.localEulerAngles.y; 
     	baseAngleDifference = Mathf.Abs(endBaseAngle-startBaseAngle);
    	if(baseAngleDifference>180){           // this bit is trying to change that angle but fails
		baseAngleDifference = Mathf.Abs(endBaseAngle-startBaseAngle);
		print("new base angleDiff = "+baseAngleDifference);
// gets called in update if changeBase is true..
    function ChangeBase(){			//small rotations should take less time. compare start and emd angle before we go here and somehow multiply rotate speed
    	weaponBase.transform.localEulerAngles.y = Mathf.Lerp(startBaseAngle,endBaseAngle,rotateTimer*baseRotateSpeed);
    	rotateTimer+=Time.deltaTime/baseAngleDifference;	//dividing by difference of old and new angle so a small angle is reached faster

Also if you have any other improvements to my coding style it would be appreciated since i am still quite new to programming. I am sure there is an easier way to do this.

thanks in advance

localEulerAngles (as well as eulerAngles) return an angle usually between 0 and 360: when the angle falls below 0, it usually becomes 359, not -1 as you could expect.

To avoid this problem (among several others…), it’s better to do it with quaternions:

var speed: float = 10; // speed in degrees per second

function Update(){
  // NOTE: rotateHelper isn't necessary to this code
  // find the target direction relative to weaponBase:
  var dir = target.transform.position - weaponBase.transform.position;
  // kill any height difference to make the direction strictly horizontal:
  dir.y = 0;
  // calculate the desired quaternion:
  var rot = Quaternion.LookRotation(dir);
  // weaponBase rotates to target at constant speed:
  weaponBase.transform.rotation = Quaternion.RotateTowards(weaponBase.transform.rotation, rot, speed * Time.deltaTime);

This code will make weaponBase rotate horizontally at speed degrees per second in the target direction, independently of rotateHelper (remove it if it’s unnecessary).