Major update to trigram function. Function working properly on this commit.