refactor groups controller