Fix looping through groups