doing matrix search