Adding n-grams function