added group by statistic functionality