Fix search condition logic