Fixed bug in save instance state