Refactor addGroup