Supporting the saveState function