Changed to using iterator in search.