Simplify groupByProject function