Generic version of findRange