Fix order of matrix elements