1 correct some error in code
2 begin write matrix to matrix