Loop in the matrix