created the matrix functions