copy/paste in cmatrix solution but rather carelessly so don't blame me