added the matrix functions