fixed logic error on search