Added autosave functionality