First and not tested version of grouping by box
Fixed the operation of the grouping function; tests

* The function seems to be ready to use.