adding error checker and matrix multiplication