I need some help, i need to "constrain" rigidbody.AddForce when im in mid air.

Hello, i know my titles was f***** but as you guys see i need some help!
I have made a simple script which adds a force to a gameobject using rigidbody (Left, right and up(JUMP))
The problem i have encounter is that when i’m in mid air i can still add a force to the object, which i want to disable. I still want the movement to be the same, i would like to “not be able” to add another force and destroy the path it is taking.

Thanks. My english sucks, please do not be some nazi grammars.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(Rigidbody))]

public class Movement : MonoBehaviour
{
    public float maxSpeed = 10f;
    public float speed = 100f;
    public Rigidbody rb;
    public float jumpHeight = 50f;
    public float rayLenght = 0.6f;

    [SerializeField]
    private bool jump;
    [SerializeField]
    private bool isGrounded;
    private float horizontal;
    private RaycastHit hit;

    void Update()
    {
        horizontal = Input.GetAxis("Horizontal");

        if (Input.GetButtonDown("Jump"))
        {
            jump = true;
        }

        CheckIfGrounded();
    }

    void FixedUpdate ()
    {
        rb.AddForce(horizontal * speed, 0f, 0f);

        if (rb.velocity.magnitude > maxSpeed)
        {
            rb.velocity = rb.velocity.normalized * maxSpeed;
        }

        if (jump && isGrounded)
        {
            rb.AddForce(0f, 100.0f * jumpHeight, 0f);

            jump = false;
            isGrounded = false;
        }
    }

    void CheckIfGrounded()
    {
        if (Physics.Raycast(transform.position, Vector3.down, out hit, rayLenght))
        {
            if (hit.transform.CompareTag("Ground"))
            {
                isGrounded = true;
            }
        }
    }
}

I see two possibilities:
A) isGrounded is not getting updated correctly

or

B) isGrounded is working, but the force is being added anyway

Can you watch the inspector during gameplay and see whether isGrounded is being set true/false correctly?

Hello thanks for replying, YES everything works, it is a working code and i sorted it out. All i had to do, was to have a goodnight sleep and then it just hit me, check if i am grounded then addforce. It was so obvious… after i started to think about it