fixed update bug in switch component, and generalized the componenent a little bit