added new optimized search function