I sometimes see these lines when a character needs to be rotated. While the first line is clear, I don’t know what the last line (with Euler Angles) is for. I can remove it or not it doesn’t change anything on the result.
transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.LookRotation(direction),rotationSpeed * Time.deltaTime);
transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);