Fix the search criteria mess

Gosh. I have to make it work with better code.