Character rotating to previous rotation

Hello! I’m pretty new to Unity scripting, but I wanted to start working on a sort of large project. I’m trying to make a third-person Pokemon-like game, where the camera can be rotated in whichever direction, and the player model will turn to face and move in that direction. I got the player model to look in the direction it’s heading, but for some reason, as soon as you stop moving, the player model turns to look in the default direction it was when you start the game, if that makes sense. Does anyone know why that might be happening? Here is the code I have so far:

public GameObject player;
public CharacterController controller;

public float playerSpeed = 10.0f;
public float rotationSpeed;

Vector3 move;

private void Start()
{
    controller = GetComponent<CharacterController>();
}

// Update is called once per frame
void Update()
{
    //Getting input from player - used for movement
    float x = Input.GetAxis("Horizontal");
    float z = Input.GetAxis("Vertical");

    //Player movement
    Vector3 movementDirection = new Vector3(x, 0, z);
    movementDirection.Normalize();
    transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(movementDirection), 0.15f);

    transform.Translate(movementDirection * playerSpeed * Time.deltaTime, Space.World);

    //Call sprint
    Sprint();
}

void Sprint()
{
    //If left shift is pressed, double movement speed. Otherwise, keep it at the default speed
    if(Input.GetKeyDown(KeyCode.LeftShift))
    {
        playerSpeed = playerSpeed * 2;
    }
    else if(Input.GetKeyUp(KeyCode.LeftShift))
    {
        playerSpeed = 10.0f;
    }
}

@Comicbook23 When you are not moving the player, the values ​​of Input.GetAxis are 0, since there is no input, therefore, x and z are also 0 and the player rotates in that direction. Check that x or z are not equal to 0 before set the rotation.