         do {
             let input = try AVCaptureDeviceInput(device: captureDevice)
             captureSession = AVCaptureSession()
-            #if swift(>=4.0)
-                captureSession.sessionPreset = AVCaptureSession.Preset.high
-            #else
-                captureSession.sessionPreset = AVCaptureSessionPresetHigh
-            #endif
+            captureSession.sessionPreset = AVCaptureSession.Preset.high
             captureSession.addInput(input)
             
             captureImageOutput = AVCaptureStillImageOutput()

        }
        var videoConnection: AVCaptureConnection? = nil
        for connection in captureImageOutput.connections {
            #if swift(>=4.0)
                if (connection.inputPorts.contains { $0.mediaType == AVMediaType.video }) {
                    videoConnection = connection
                    break
                }
                if videoConnection != nil {
                    break
                }
            #else
                if let connection = connection as? AVCaptureConnection {
                    if (connection.inputPorts.contains {
                        if let inputPort = $0 as? AVCaptureInputPort {
                            return inputPort.mediaType == AVMediaTypeVideo
                        }
                        return false
                    }) {
                        videoConnection = connection
                        break
                    }
                    if videoConnection != nil {
                        break
                    }
                }
            #endif
        }
        
        captureImageOutput.captureStillImageAsynchronously(from: videoConnection!) { (imageSampleBuffer: CMSampleBuffer?, _: Error?) -> Void in

                
                captureMetadataOutput = AVCaptureMetadataOutput()
                captureSession.addOutput(captureMetadataOutput)
                captureMetadataOutput.metadataObjectTypes = metadataTypes.filter { captureMetadataOutput.availableMetadataObjectTypes.contains($0) }
                captureMetadataOutput.setMetadataObjectsDelegate(self, queue:dispatchQueue)
            case .takePhoto: break
            }
            
            captureImageOutput.outputSettings = [AVVideoCodecKey: AVVideoCodecJPEG]
            videoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
            videoPreviewLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill
            videoPreviewLayer.frame = inView.layer.bounds
            inView.layer.addSublayer(videoPreviewLayer)
            videoPreviewView = inView
