changing group_by to follow best practices