Fix incorrect recognition of Y-D-M pattern