                 self.flashButton.isHidden = true
             }
             
+            #if swift(>=4.0)
             for oldInput in self.captureSession.inputs {
                 self.captureSession.removeInput(oldInput)
             }
+            #else
+            for oldInput in self.captureSession.inputs as! [AVCaptureInput] {
+                self.captureSession.removeInput(oldInput)
+            }
+            #endif
             
             if let frontInput = try? AVCaptureDeviceInput(device: currentDevice) {
                 if self.captureSession.canAddInput(frontInput) {

    
    private var imageData: Data?
    
    func photoOutput(_ output: AVCapturePhotoOutput,
                     didFinishProcessingPhoto photoSampleBuffer: CMSampleBuffer?,
                     previewPhoto previewPhotoSampleBuffer: CMSampleBuffer?,

    // MARK: - Capture Image
    
    @objc open func takePicture() {
        #if swift(>=4.0)
        let authStatus = AVCaptureDevice.authorizationStatus(for: .video)
        #else
        let authStatus = AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo)
        #endif
        
        if authStatus == .denied {
            return
        }
