Fix crashing bug caused by the switch changes.