updates to ngram logic