trying to implement autosave loop