Added a groupBy method