Refactor mdswitch demo