add restore function and update error messages