Fix pattern priority matching