added grouping query