improvements to the search algorithm