fixed some search logic