make submatrix more efficient