a kind-of-working but dirty version of mdg switching