Added grouping code.