     let app = FirebaseApp.app(name: "FirebaseLogs")!
     let database = Database.database(app: app)
     database.isPersistenceEnabled = true
-    firebaseRef = Database.database(app: app).reference()
+    let firebaseRef = Database.database(app: app).reference()
     //check encryption
     if let encryptionParams = encryptionParams {
       guard let aesEncoder = try? AES(key: encryptionParams.key, iv: encryptionParams.iv) else {
         return nil
       }
-      self.aesEncoder = aesEncoder
+      saveStrategy = EncryptedFirebaseSaveStrategy(firebaseRef: firebaseRef, aesEncoder: aesEncoder)
     } else {
-      self.aesEncoder = nil
+      saveStrategy = SimpleFirebaseSaveStrategy(firebaseRef: firebaseRef)
     }
-
   }
   
   public override func output(logDetails: LogDetails, message: String) {


    self.applyFormatters(logDetails: &logDetails, message: &message)
    //store log detail
    let logsRef = firebaseRef.child("Logs")
    if aesEncoder != nil {
      let encryptedDaga = encryptLogData(logDetails: logDetails)
      logsRef.child(message.md5()).setValue(encryptedDaga)
    } else {
      logsRef.child(message.md5()).setValue(logDetails.json)
    }
  }

  private func encryptLogData(logDetails: LogDetails) -> String {
    let data = try! JSONSerialization.data(withJSONObject: logDetails.json, options: JSONSerialization.WritingOptions(rawValue: 0))
    let raw = try! aesEncoder!.encrypt(data)
    let encryptedData = Data(bytes: raw)
    return encryptedData.toHexString()
  }
}

      self.iv = iv
    }
  }
  private let saveStrategy: SaveStrategy
  /**
   Designated initialization

