Changed the return value of search_with_cost to be a tuple