saving status of code before switching