refactored some code related to groups
commit