Improved the search algorithm.