New code to control switch