Listener for switch control