update switching code