Refactor: Removing unneccessary recursion is_in_hybrid_grid and is_in_grid