Added logic for identifying trigrams