coding the matrix