Can't set animator bool to True

I am trying to write a simple point and click movement system. I press a point and my character moves there using navmesh. Everything works. I press a point, a marker is set and my character moves there. There is a small problem with the animation however. First here is the code i am using:

	void Update () {

				if (Input.GetKeyUp(KeyCode.Mouse0)) {
						ray = characterCamera.ScreenPointToRay (Input.mousePosition);
						didHit=Physics.Raycast (ray, out hit);
						if (didHit && hit.collider.tag=="Travel") {
							anim.SetBool ("Walking",true);
							Debug.Log ("Walking: true");
							if (currentMarker!=null){
								Destroy (currentMarker);
							}
							rayHitPosition=hit.point;
							currentMarker=Instantiate (Marker,rayHitPosition,Quaternion.Euler (Vector3.zero));
							agent.destination=rayHitPosition;
						}
				}
				if (agent.remainingDistance<=0)
				{
					anim.SetBool ("Walking",false);
				}
		}

My Walking bool sometimes won’t set to true. When i set press my mouse for the first time the bool won’t set to true however if i press again WHILE the agent is in motion then the bool will set to true and the animation play. Anything i am missin? Why won’t it set the bool on the first click?

Found the answer. The navmeshagent remainingDistance is only calculated after the frame in which the destination was changed. Instead of checking if agent.remainingDistance is 0 I used vector3.distance to calculate the remaining distance manually.