Finally debugged count_ngrams