Added function save state