add groupBy, countBy and toArray