Refactor i2c double switch