added grouping, trimmed ids, removed 'rowz' variable name