     }
     
     //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

import AVFoundation
import UIKit

public class CodeScannerView: UIView {
    private var captureSession: AVCaptureSession?
    private weak var captureMetadataOutputObjectsDelegate: AVCaptureMetadataOutputObjectsDelegate?
    private var scanCompleteBlock: ((_ message: String, _ error: String?)->())?
    
    let q = DispatchQueue(label: "CodeScannerViewQueue")
    
    private lazy var captureMetadataOutput: AVCaptureMetadataOutput = {
        let captureMetadataOutput = AVCaptureMetadataOutput()
        captureMetadataOutput.setMetadataObjectsDelegate(captureMetadataOutputObjectsDelegate, queue: q)
        return captureMetadataOutput
    }()
    
    private var videoPreviewLayer: AVCaptureVideoPreviewLayer? {
        didSet {
            oldValue?.removeFromSuperlayer()

        super.removeFromSuperview()
    }
    
    public func startReading(completion: ((_ error: Error?)->())?) {
        if isFreezing && !isScanning {
            resumeReading()
            completion?(nil)
        }
        
        self.captureSession = AVCaptureSession()
