Air control in character controller keeping velocity but being able to correct course?

Hi, I made this function to move the Character Controller. However I want to be able to jump and if the player was moving forward, it should realistically keep that direction, but also move a little bit so the player can correct the course and land properly.

The problem with my code is that if the player was running forward and then jumps, it works as intended, but if the player moves forwards, it all adds up and moves even faster, making it more efficient to jump instead of running. I guess there’s must be a simple solution but I just can’t grasp it since i’m not that good with vectors.

void Move() {

        //gets forward an right vector relative to player view
        Vector3 forward = transform.forward;
        Vector3 right = transform.right;

        //player movement
        float xSpeed = Input.GetAxis("Vertical") * speed;
        float ySpeed = Input.GetAxis("Horizontal") * speed;

        moveDirection = (forward * xSpeed) + (right * ySpeed);

        if (isGrounded) {
            lastDirection = moveDirection;

        //if it's not grounde then apply air control
        if (!isGrounded) {
            moveDirection = lastDirection + (moveDirection * airControl);
        characterController.Move(moveDirection * Time.deltaTime);


thx you helped me, but how can i detect players last movementdirection,thx u helped me.