Got matching algorithm for vert + horiz combined working