I changed what `count` was based on from `matches` to `ngroups`. This seems wrong to me (based on the property names), but it is how it was done in the existing code. Any ideas?