Improve reliability of saving database.