Look rotation makes sudden changes

This is a racing game, I use A* Pathfinding Project pathfinder for the character runs on a oval racetrack. Player can only play with the characters speed which is calculated and has a high limit. When the player reaches high range of speed character suddenly looks left or right for a moment and straightens back and its very annoying. Its not happening with low speed. What am i missing? The dir vector is calculated same with the astar tutorials. I also use simple smooth modifier.

               dir = (path.vectorPath [currentWaypoint] - transform.position).normalized;
       Vector3 rot = dir;
             rot.y = 0f;
var targetRotation = Quaternion.LookRotation (rot, Vector3.up);
transform.rotation = Quaternion.Slerp (transform.rotation, targetRotation, Time.deltaTime * speed * 0.3f);

characterController.SimpleMove (dir * speed * 0.8f);

I found a solution:

When i checked the angles between dir and transform.position the values are like:

143.7691
143.8332
.
.
145.8065
.
.
52.40902 (eww!)
.
.
140.2589

I dont know why my direction vector changes suddenly. Now im checking for sudden angle change and it seems ok, probably not the best solution.