Rewrote the matrix into a structure