Fixed the addition and removal of group elements in the DOM