Possibly fixed search logic. Untested