             NSLayoutConstraint(item: guide, attribute: .width, relatedBy: .equal, toItem: guide, attribute: .height, multiplier: 1.0, constant: 0.0) ])
         guide.transform = CGAffineTransform(scaleX: 0.0, y: 0.0)
 
-        close.addTarget(self, action: #selector(ScanViewController.closeTapped), for: .touchUpInside)
+        close.tap = {
+            self.dismiss(animated: true, completion: {
+                self.completion(nil)
+            })
+        }
 
         addCameraPreview()
     }

    }

    private func addCameraPreview() {
        let device = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo)
        guard let input = try? AVCaptureDeviceInput(device: device) else { return }
        session.addInput(input)
        guard let previewLayer = AVCaptureVideoPreviewLayer(session: session) else { assert(false); return }

        DispatchQueue(label: "qrscanner").async {
            self.session.startRunning()
        }

        if device.hasTorch {
            flash.tap = {
                do {
                    try device.lockForConfiguration()
                    device.torchMode = device.torchMode == .on ? .off : .on
                    device.unlockForConfiguration()
                } catch let error {
                    print("Camera Torch error: \(error)")
                }
            }
        }
    }

    override var prefersStatusBarHidden: Bool {
        return true
    }

    required init?(coder aDecoder: NSCoder) {
