Smooth 90 degree turn

I modified a script that Joachim Ante wrote a while ago to try to create a smooth 90 turn but it doesn’t want to work.

The idea is that you hit the ‘b’ key to turn 90 degrees to the right. I have it working another way but it is frame dependent so I wanted to improve upon it.

var startrotation = 270;

function Update () {

 	if (Input. GetKeyDown ("b")) { 
		StartCoroutine("Slerp", 1.0); 
	}
}

function Slerp (time : float) 
{ 
  var curroation : Vector3;
  var newrotation : Vector3;
  var originalTime = time;  
     
    curroation = Vector3(0, startrotation, 0);
	newrotation = Vector3(0,(startrotation + 90),0); 

    startrotation = startrotation + 90;
  
   while (time > 0.0) 
   { 
      time -= Time.deltaTime; 
      transform.rotation = Quaternion.Slerp(curroation, newrotation, time / originalTime); 
      yield; 
   } 
}

Thoughts?

I did some digging and found my error.

var startrotation = 270;

function Update () {

 	if (Input. GetKeyDown ("b")) { 
		StartCoroutine("Slerp", 1.0); 
	}
}

function Slerp (time : float) 
{ 
	var curroation = Quaternion.Euler(0, startrotation, 0);
	var newrotation = Quaternion.Euler(0, (startrotation + 90), 0);
  	var originalTime = time;  

	startrotation = startrotation + 90;
  
   while (time > 0.0) 
   { 
      time -= Time.deltaTime; 
      transform.rotation = Quaternion.Slerp(newrotation, curroation, time / originalTime); 
      yield; 
   } 
}