Rewrite search in a thread