update and regroup Gray_Code