Smoother Rotation with mouse

I have a characterController where the Character rotates with Input.mousePosition.x
Thats my Code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;

public class C2 : MonoBehaviour
{
    public float Speed;
    public float delta;
    private float lastP;
    float MousePos = Input.mousePosition.x;
    private void Start()
    {
        Speed = 0.08f;
    }

    private void Update()
    {
       

        if (Input.GetButtonDown("Fire2"))
        {
            
            lastP = MousePos;
        }
        else if (Input.GetButton("Fire2"))
        {
            MousePos = Input.mousePosition.x;
            delta = MousePos - lastP;

            Debug.Log(delta);

            transform.Rotate(0, delta * 0.5f, 0);

            lastP = MousePos;
        }
    }
}

my Problem is that when i release fire2 and move my mouse and the click fire2 again it rotates to this position and its really unsoomth

pls help

Hey, would be nice if you could tell us what you controller should do.

test this code

         else if (Input.GetButton("Fire2"))
         {
             MousePos = Input.mousePosition.x;
             delta = MousePos - lastP;
 
             Debug.Log(delta);

             Quaternion target = Quaternion.Euler(0, delta * 0.5f, 0);

             transform.rotation = Quaternion.RotateTowards(transform.rotation, target, Speed);

             lastP = MousePos;
         }