fixes bugs, added check a matrix is zero and check if the matrix is the same