Since I don't know what you're trying to do and what your search functions do, I cannot comment on a proper solution.
Since I don't know what you're trying to do and what your search functions do, I cannot comment on a proper solution.