fixed a bug with duplicate groups