fix parsing optional groups (did not detect consecutive optional groups