lots of work done on saving state