Double jump while climbing ladder

Hello all! I am working in a 2D platformer and have an OnJump() and ClimbLadder() function working well separately. The problem is that the player object can’t jump twice after touching the “Ladder” layer. I have a pseudo jump method inside ClimbLadder(). The problem is that I’m decrementing the numOfJumps every time the input is pressed on the original OnJump() method, but since the ClimbLadder() is called in update, it is decrementing the numOfJumps every frame. Can anyone suggest a way to work around this, or give some pointers please? Thank you!

Note: CheckIfGrounded() is also called in Update if that wasnt clear. I would expect this to be able to read that the gameObject is touching the “Ladder” layer and reset the numOfJumps to 2.

    // Jump Variables
    bool isAlive = true;
    int numOfJumps = 2;
    bool wasGrounded = true;
    [SerializeField] float jumpSpeed = 5f;

    public void OnJump(InputValue value)
    {
        if (isDashing)
        { return; }

        if (!isAlive) 
        { return; }

        if (value.isPressed && numOfJumps >= 1)
        {
            numOfJumps --;
            myRigidbody.velocity = new Vector3(myRigidbody.velocity.x, 0f);

            myRigidbody.velocity += new Vector2(0f, jumpSpeed);
            Debug.Log("Jumped! Remaining jumps: " + numOfJumps);
        }
    }
    void ClimbLadder()
    {
        if (!isAlive) {return;}

        if (!myFeetCollider.IsTouchingLayers(LayerMask.GetMask("Ladder")))
        {   
            myRigidbody.gravityScale = gravityScaleAtStart;
            return;
        }

        Vector2 climbVelocity = new Vector2 (myRigidbody.velocity.x, moveInput.y * climbSpeed);
        myRigidbody.velocity = climbVelocity;
        myRigidbody.gravityScale = 0f;

        if (Input.GetButton("Jump"))
        {
            numOfJumps --;
            myRigidbody.velocity = new Vector3(myRigidbody.velocity.x, 0f);

            myRigidbody.velocity += new Vector2(0f, jumpSpeed);
            Debug.Log("Jumped! Remaining jumps: " + numOfJumps);
        
        }
    }
    void CheckIfGrounded()
    {
        bool isCurrentlyGrounded = myFeetCollider.IsTouchingLayers(LayerMask.GetMask("Environment", "Enemies", "Ladder"));

        if (!wasGrounded && isCurrentlyGrounded)
        {
            numOfJumps = 2;
        }

        wasGrounded = isCurrentlyGrounded;
    }