traverseMatrix