prototyped save and restore snippet