Move object towards mouse position

Hi,

I have this code which has some strange results:

if(isPanning && Input.GetMouseButton(0)) //panning
		{
			
			Ray mouseSyncRay1 = Camera.main.ScreenPointToRay(Input.mousePosition);
			Physics.Raycast(mouseSyncRay1, out mouseSyncHit);
			Debug.DrawLine(mouseSyncRay1.origin, mouseSyncHit.point, Color.red);
			
			targetPanPos = mouseSyncHit.point - cameraHolder.transform.position;
			
			cameraHolder.transform.position = Vector3.Lerp(cameraHolder.transform.position, targetPanPos, Time.deltaTime * 2f);
			
			
			
		}

The idea was to raycast onto my scene to see where the mouse is, in projection, and move the camera there. However, if I click and keep my mouse there, the camera always under/overshoots. Any idea how to make the camera move exactly to where the mouse is? Considering this code is in update.

Solved it myself. Only lerp if the mouse position has not changed.

if(isPanning && Input.GetMouseButton(0)) //panning
		{
			
			Ray mouseSyncRay1 = Camera.main.ScreenPointToRay(Input.mousePosition);
			Physics.Raycast(mouseSyncRay1, out mouseSyncHit);
			Debug.DrawLine(mouseSyncRay1.origin, mouseSyncHit.point, Color.red);
			
			if(!((Vector2)(lastMousePos) == (Vector2)Input.mousePosition))
			{
				needToPan = true;
				panEndPos = mouseSyncHit.point;
			}
			
			lastMousePos = Input.mousePosition;
			
			clampCameraBounds();
			
		}

if(needToPan)
		{
			//targetPanPos = mouseSyncHit.point - cameraHolder.transform.position;
			
			cameraHolder.transform.position = Vector3.Lerp(cameraHolder.transform.position, panEndPos, Time.deltaTime * 2f);
			if(cameraHolder.transform.position == panEndPos)
				needToPan = false;
		}