improved parser case grouping