modify loop search for db