Rewriting grouping functionality to use selector.