added grid finding routine