Optimizes multi-variable matches