dtm refactoring for n-grams