Fixed search algorithm.

Fixed search algorithm.