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

:smiling_imp: 

Please pull and confirm all is good.