Wrote the matrix code