Weird cam movement on two touches

When I put my finger on empty area of screen (not over any UI) and then I click on my joystick with another finger it causes weird rotational glitch between those two touches, I guess it is confused between two touches
public class MouseController : MonoBehaviour
{
[Header(“X Axis”)]
public float sensitivityX = 4f; // Mouse look sensitivity.

    [Header("Y Axis")]
	public float sensitivityY = 4f; // Mouse look sensitivity.

    [Range(-360, 360)]
    public float maximumY = 60f; // Maximum angle you can look up.

    [Range(-360, 360)]
    public float minimumY = -60f; // Minimum angle you can look down.

    [Space()]
    public int frameCounter = 10; // Number of frames to be averaged, used for smoothing mouselook.
    public MoveController controller; // Player.
 
    //Mouse rotation input
    private float rotationX = 0f;
    private float rotationY = 0f;

    //Used to calculate the rotation of this object
    private Quaternion xQuaternion;
    private Quaternion yQuaternion;
    private Quaternion originalRotation;
 
    //Array of rotations to be averaged
    private List<float> rotArrayX = new List<float> ();
    private List<float> rotArrayY = new List<float> ();
    GameObject fireButton;
 
    private void Start ()
    {
  		if (GetComponent<Rigidbody>())
  			GetComponent<Rigidbody>().freezeRotation = true;

       	originalRotation = transform.localRotation;
DisableMouseTouch();
fireButton = GameObject.Find("Fire");
    }

   public void DisableMouseTouch()
    {
        Input.simulateMouseWithTouches = false;
    }
private int fireButtonTouchId;
private bool isPointerOverUI;
private void Update()
{
    float rotAverageX = 0f;

    // Loop through all active touches
    for (int i = 0; i < Input.touchCount; i++)
    {
        Touch touch = Input.GetTouch(i);

        // Check if the touch is over a UI element
        isPointerOverUI = EventSystem.current.IsPointerOverGameObject(touch.fingerId);

        // Process the touch if it's not over a UI element or if it's over the fire button and is being held down
        bool isFireButton = EventSystem.current.currentSelectedGameObject == fireButton;
        bool isFireButtonHeld = touch.fingerId == fireButtonTouchId && touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled;

        if (!isPointerOverUI || (isFireButtonHeld && isFireButton))
        {
             Vector2 delta = touch.deltaPosition;
            float deltaX = delta.x * (controller.isAiming ? sensitivityX * 0.5f : sensitivityX);
            float deltaY = delta.y * (controller.isAiming ? sensitivityY * 0.5f : sensitivityY);
                // Rotate the camera based on touch delta
                rotationX += deltaX;
                rotationY += deltaY;
                rotationY = ClampAngle(rotationY, minimumY, maximumY);

                rotArrayX.Add(rotationX);
                if (rotArrayX.Count >= frameCounter)
                {
                    rotArrayX.RemoveAt(0);
                }

                rotArrayY.Add(rotationY);
                if (rotArrayY.Count >= frameCounter)
                {
                    rotArrayY.RemoveAt(0);
                }

                float rotAverageY = 0f;
                for (int i_counterY = 0; i_counterY < rotArrayY.Count; i_counterY++)
                {
                    rotAverageY += rotArrayY[i_counterY];
                }
                rotAverageY /= rotArrayY.Count;
                yQuaternion = Quaternion.AngleAxis(rotAverageY, Vector3.left);

                for (int i_counterX = 0; i_counterX < rotArrayX.Count; i_counterX++)
                {
                    rotAverageX += rotArrayX[i_counterX];
                }
                rotAverageX /= rotArrayX.Count;

                xQuaternion = Quaternion.AngleAxis(rotAverageX, Vector3.up);
                transform.localRotation = originalRotation * xQuaternion * yQuaternion;
            }
        }
    

    // Process fire button touch separately
    foreach (Touch touch in Input.touches)
    {
        if (touch.phase == TouchPhase.Began)
        {
            // Check if the touch is over the fire button
            bool isFireButton = EventSystem.current.currentSelectedGameObject == fireButton;

            if (isFireButton)
            {
                // Store the touch ID so we can track it separately from other touches
                fireButtonTouchId = touch.fingerId;
                break;
            }
        }
        else if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled)
        {
            if (touch.fingerId == fireButtonTouchId)
            {
                fireButtonTouchId = -1;
                break;
            }
        }
    }
}



    /// <summary>
    /// Clamps an angle between mininum and maximum values.
    /// Parameters: The angle, minimum and maximum values.
    /// </summary>
    private float ClampAngle (float angle, float min, float max)
    {
 		if (angle < -360f)
         	angle += 360f;
 
       	if (angle > 360f)
         	angle -= 360f;

       	return Mathf.Clamp (angle, min, max);
    }