fixed search logic