added ngrams function