     
     // re-entrant configuration lock, thanks to SCRecorder
     internal func beginConfiguration() {
-        if let session = self._captureSession {
-            self._sessionConfigurationCount += 1
-            if self._sessionConfigurationCount == 1 {
-                session.beginConfiguration()
-            }
+        guard let session = self._captureSession else {
+            return
+        }
+
+        self._sessionConfigurationCount += 1
+        if self._sessionConfigurationCount == 1 {
+            session.beginConfiguration()
         }
     }
     
     internal func commitConfiguration() {
-        if let session = self._captureSession {
-            self._sessionConfigurationCount -= 1
-            if self._sessionConfigurationCount == 0 {
-                session.commitConfiguration()
-            }
+        guard let session = self._captureSession else {
+            return
+        }
+        
+        self._sessionConfigurationCount -= 1
+        if self._sessionConfigurationCount == 0 {
+            session.commitConfiguration()
         }
     }
     
     internal func configureSessionDevices() {
-        guard self._captureSession != nil else {
+        guard let _ = self._captureSession else {
             return
         }
         

    /// Checks if focus lock is supported.
    public var isFocusLockSupported: Bool {
        get {
            if let device: AVCaptureDevice = self._currentDevice {
                return device.isFocusModeSupported(.locked)
            }
            return false

    }
    
    internal func configureSession() {
        guard let session = self._captureSession else {
            return
        }

        self.beginConfiguration()
            
        // setup preset and mode
        
        self.removeUnusedOutputsForCurrentCameraMode(session: session)
        
        switch self.captureMode {
        case .video:
            fallthrough
        case .videoWithoutAudio:
            if session.sessionPreset != self.videoConfiguration.preset {
                if session.canSetSessionPreset(self.videoConfiguration.preset) {
                    session.sessionPreset = self.videoConfiguration.preset
                } else {
                    print("NextLevel, could not set preset on session")
                }
            }
            
            if self.captureMode == .video {
                let _ = self.addAudioOuput()
            }
            let _ = self.addVideoOutput()
            if self.depthDataCaptureEnabled {
                let _ = self.addDepthDataOutput()
            }
            break
        case .photo:
            if session.sessionPreset != self.photoConfiguration.preset {
                if session.canSetSessionPreset(self.photoConfiguration.preset) {
                    session.sessionPreset = self.photoConfiguration.preset
                } else {
                    print("NextLevel, could not set preset on session")
                }
            }
            
            let _ = self.addPhotoOutput()
            if self.depthDataCaptureEnabled {
                let _ = self.addDepthDataOutput()
            }
            break
        case .audio:
            let _ = self.addAudioOuput()
            break
        case .arKit:
            // no AV inputs to setup
            break
        }
        
        self.commitConfiguration()
    }
    
    // inputs
