fix bugs in switch control