replaced switches with factories.