working on ngram freq algorithm