Refactor the res_search() fail hack