searching implemented efficiently