almost done! new search algorithm