Refactor and add groups