Fix a bug when wrapping the search.