stop rotating towards

I been trying to get this function to stop rotating when the model does not have to rotate anymore. I have tried checking the models current rotation against the look rotation to see if they are the same. I have also tried comparing the y value of the quaternions because thats what I am rotating on. Any help would be greatly appreciated.

function RotateTowards (position : Vector3) : boolean {
	var direction = position - transform.position;
	direction.y = 0;
	
	if( transform. rotation ==Quaternion.LookRotation(direction))
		return  true;

	// Rotate towards the target
	transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.LookRotation(direction), rotationSpeed * Time.deltaTime);
	//transform.eulerAngles = Vector3(0, transform.eulerAngles.y, 0);
	
	return false;

}

I tried this before and also had no luck. I believe it doesn’t work because of the lack of precision in floating point numbers. I ultimately decided to change my code to Slerp over a fixed amount of time, so I could be sure when the rotation had finished.

Yeah I think it is something to do with floats I even tried adding a threshold. Sadly Slerping over time will not work very well for my game. I guess I will keep trying.