Moved the matching of expressions outside the for loop.