modified: groupBy method