Added functionality to group by several variables