optimization: move match suffixes out of function, and use set instead of list