added ngram functions