now with proper grouping