             return
         }
         
-        print("restoreTransaction... \(productIdentifier)")
+        log.warning("restoreTransaction... \(productIdentifier)")
         deliverPurchasedNotificationForIdentifier(productIdentifier)
         SKPaymentQueue.default().finishTransaction(transaction)
         Answers.logContentView(withName: "Purchase restored", contentType: "IAP", contentId: Date().dateString, customAttributes: nil)
     }
     
     fileprivate func failedTransaction(_ transaction: SKPaymentTransaction) {
-        print("failedTransaction...")
-        if transaction.error!.code != SKError.paymentCancelled.rawValue {
-            print("Transaction Error: \(transaction.error?.localizedDescription)")
-            if let desc = transaction.error?.localizedDescription {
-                Answers.logContentView(withName: "Purchase failed",
-                                               contentType: "IAP",
-                                               contentId: Date().dateString,
-                                               customAttributes: ["Error": desc])
+        log.warning("failedTransaction...")
+        if let transactionError = transaction.error as? SKError{
+            
+            if transactionError.code != SKError.paymentCancelled {
+                log.warning("Transaction Error: \(transaction.error?.localizedDescription)")
+                if let desc = transaction.error?.localizedDescription {
+                    Answers.logContentView(withName: "Purchase failed",
+                                                   contentType: "IAP",
+                                                   contentId: Date().dateString,
+                                                   customAttributes: ["Error": desc])
+                }
             }
         }
         

    }
    
    public func buyProduct(_ product: SKProduct) {
        print("Buying \(product.productIdentifier)...")
        let payment = SKPayment(product: product)
        SKPaymentQueue.default().add(payment)
    }

            let purchased = UserDefaults.standard.bool(forKey: productIdentifier)
            if purchased {
                purchasedProductIdentifiers.insert(productIdentifier)
                log.info("Previously purchased: \(productIdentifier)")
            } else {
                log.info("Not purchased: \(productIdentifier)")
            }
        }
        super.init()
