Rewrite the loop in SearchManager