How to avoid overlapping of groups