ngram implementation done