Latest code - doesnt work, but want to save state before context switching