Make Player Run and Walk at Different Distance

Hello, I’m controlling my player by using “click to move to target position” method. However, I want him to “walk to target” if I click at a distance that is closer to him and “run to target” if I click at a further distance.
I already tried this, however, when my player runs to target, he switches to walk when he reaches the distance between him and the target position. I am new to Unity and I would be really appreciate if someone could come up with a solution. Thank you!

     targetPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    ` float dist = Vector3.Distance(targetPosition, transform.position);
                            if (dist.x >= 8)
                            {
                                Run();
                            }
                            else
                            {
                                Walk();
                            }   
         void Walk()
    {
        speed = 2.5f;
        transform.position = Vector3.MoveTowards(transform.position, targetPosition, speed * Time.deltaTime);
        anim.SetBool("Run", false);
        anim.SetBool("Walk", true);
        if (transform.position == targetPosition)
        {
            isMoving = false;
            anim.SetBool("Walk", false);
        }
    }
    void Run()
    {
        speed = 3.5f;
        transform.position = Vector3.MoveTowards(transform.position, targetPosition, speed * Time.deltaTime);
        anim.SetBool("Walk", false);
        anim.SetBool("Run", true);
        if (transform.position == targetPosition)
        {
            isMoving = false;
            anim.SetBool("Run", false);
        }
    }

@kobatonguye, So, you don’t want the character to switch back to walking after starting to run to the target location? Then only do the check when you first initiate the run or walk, do not constantly check the distance as it is moving.

We can’t tell because you haven’t provided the code that shows where your distance check is, but if that is in an Update loop it will check every frame, which is not where it should be given your problem.