jumping issue 2d platformer

I hope i can get help on this because have been trying for some time and cant get my head around it,. I have a triple jump in my game it is working perfect, but when i leave the grounded platform e.g fall off the edge i want to be able to still triple jump to try jump back up to the platform i fell off. For some reason i can only double jump after the fall heres my code:

if (Input.GetKeyDown(KeyCode.W)&& extraJumps >0)

    {

        rb.velocity = Vector2.up * jumpForce;
        extraJumps--;
        anim.SetTrigger("jump");
        jumpSound.Play();
    }

    else if(Input.GetKey(KeyCode.W)&& extraJumps ==0 && isGrounded == true)
    
    {
        rb.velocity = Vector2.up * jumpForce;
        Debug.Log("PlayAnim");

    }

I think the problem may be rb.velocity part from when im grounded is there a way i can fix this to be able to triple jump after a fall… if anyone can help me that would be great thanks.

Well you have your boolean isGrounded and you can tell by that when your character is up in the air. You should add another one called isFalling. To check it when player lands on platform for the first time you should save his grounded Y position so whenever he falls of that platform and his Y is lower then grounded that means hes falling. Each platform you gonna land you should replace this variable. Should work good luck!