restructured for Demo, including DemoMain(switch)