Pivoting camera

Hi,
Since a few days i’m trying to create an isometic camera, which rotates exactly 90 degrees when i press Q or E. (counterclock and clockwise). after alot of searching on the forums etc i came up with this code:

void Update()
{
if (Input.GetKeyDown(KeyCode.Q))
        {
            Ray ray = cam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
            Physics.Raycast(cam.transform.position, cam.transform.forward, out hit);

            if (!rotating)
            {
                rotating = true;
                StartCoroutine(rotate(rotateTime, angle, step));
            }
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            Ray ray = cam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
            Physics.Raycast(cam.transform.position, cam.transform.forward, out hit);

            if (!rotating)
            {
                rotating = true;
                StartCoroutine(rotate(rotateTime, -angle, step));
            }
        }
    }

    IEnumerator rotate(float time, float angle, float step)
    {
        if (rotating)
            yield return false;

        Vector3 beginAngle = cam.transform.rotation.eulerAngles;

        float totalSteps = time / step;
        float angleStep = angle / totalSteps;

        for (float f = 0f; f <= time; f += step)
        {
            cam.transform.RotateAround(hit.transform.position, Vector3.up, angleStep);
            yield return new WaitForSeconds(step);
        }
        rotating = false;
    }

but there is a small offset at the end, like 1 or 2 degrees, which builds up over time as i rotate more and more. I just want 45, 135, 225 or 315 degrees exact. How should I fix this?

bump.
anyone?