replace binary codes with gray codes