use yield for search to reduce memory use