diff --git a/src/lokijs.js b/src/lokijs.js
index <HASH>..<HASH> 100644
--- a/src/lokijs.js
+++ b/src/lokijs.js
@@ -1472,12 +1472,13 @@
      * @memberof LokiFsAdapter
      */
     LokiFsAdapter.prototype.saveDatabase = function saveDatabase(dbname, dbstring, callback) {
+      var self = this;
       var tmpdbname = dbname + '~';
       this.fs.writeFile(tmpdbname, dbstring, function writeFileCallback(err) {
         if (err) {
           callback(new Error(err));
         } else {
-          this.fs.rename(tmpdbname,dbname,callback);
+          self.fs.rename(tmpdbname,dbname,callback);
         }
       });
     };
Fixed 'this' scoping in saveDatabase