added submatrix function