begin debug reversematrix function