Bug with double when using new Input system

hi guys, I am making a 2.5D runner game

This is the code for jumping & double jumping this same way was working fine with the legacy input system. but want to switch from legacy because I want to release the game for both smartphones and desktops, With the new input system when I press jump character goes into double jumping automatically even if I only press space once. I want Control.double jump to trigger double jump animation when I press jump twice and I don’t know how to do that need help with it.

public void JumpMethod ( InputAction.CallbackContext context )
{
    if (context.performed)
    {
        if (!control.StartRun)
        {
            control.StartRun = true;
        }
        else
        {
            control.Jump = true;
        }

        if(control.Grounded && control.CanDoubleJump)
        {
            control.DoubleJump = true;
        }
    }
    else
    {
        control.DoubleJump = false;
        control.Jump = false;
    }
}

legacy input system code I am using a state machine pattern and this code runs on jump state

using UnityEngine;

namespace EndlessRunning
{
    [CreateAssetMenu(fileName = "New Object", menuName = "ScriptableObject/Ability/DoubleJump")]
    public class DoubleJump : ScriptableObjectData
    {
       [SerializeField]
        private bool CanDoubleJump = true;

        public override void OnEnter(PlayerStateBase playerStateBase, Animator animator, AnimatorStateInfo stateInfo)
        {

        }
        public override void OnUpdate(PlayerStateBase playerStateBase, Animator animator, AnimatorStateInfo stateInfo)
        {

            if (playerStateBase.characterControl.Grounded)
            {
                CanDoubleJump = true;
            }
            else
            {
                if (CanDoubleJump && playerStateBase.characterControl.Jump)
                {
                    animator.SetBool(HashManger.Instance.DicMainParameters[AnimatorParameters.DoubleJump], true);
                    CanDoubleJump = false;
                }
            }
        }

        public override void OnExit(PlayerStateBase playerStateBase, Animator animator, AnimatorStateInfo stateInfo)
        {
        }
    }
}

If I understand your code correctly you’re currently setting control.DoubleJump to true if the player is grounded when pressing the Jump button.
Shouldn’t it be when the player is not grounded?