working on grouping and sorting