adds group by method