refactor group update code