remade search by reference code
remove old code from model