fix group_by statements