     }
     
     //Use view's AVCaptureMetadataOutputObjectsDelegate with completion closure
-    public init(frame: CGRect = UIScreen.main.bounds, scanCompletion: @escaping (_ message: String, _ error: String?)->() ) {
+    public init(frame: CGRect = UIScreen.main.bounds, scanCompletion: @escaping (_ message: String?, _ error: String?)->() ) {
         super.init(frame: frame)
         self.captureMetadataOutputObjectsDelegate = self
         self.scanCompleteBlock = scanCompletion

        }
        
        q.async {
            let captureDevice = AVCaptureDevice.default(for: .video)!
            let input = try! AVCaptureDeviceInput(device: captureDevice)
            captureSession.addInput(input)
            let previewLayer = self.setupPreviewLayer(session: captureSession)
            self.setupMetadataOutput()
            captureSession.startRunning()
            
            DispatchQueue.main.async {
                self.videoPreviewLayer = previewLayer
                self.isScanning = true
            }
        }
    }

        
        AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
        
        if let readableObj = obj as? AVMetadataMachineReadableCodeObject {
            guard let str = readableObj.stringValue else {
                error = "Invalid Code"
                return
            }
            code = str
        } else {
            error = "Wrong code type or invalid code"
        }
    }
}
