Factor matching code that is common between patterns. This works around