autosaves main and procedure