fix a bug on grouping