implement q-search