fix Search logic