automatic group count, fixing vars' names