optimize search query: from 100's of queries to 2!

:smiling_imp: