updated the savedinstancestate to work correctly