match groups better by shortest prefix