Simplify a condition in search()