             return .off
         }
         set {
-            if let _ = self._captureSession,
-                let videoOutput = self._videoOutput {
-                
-                switch newValue {
-                case .off:
-                    if let vc = videoOutput.connection(with: AVMediaType.video) {
-                        if vc.isVideoMirroringSupported {
-                            vc.isVideoMirrored = false
-                        }
-                    }
-                    if let pc = self.previewLayer.connection {
-                        if pc.isVideoMirroringSupported {
-                            pc.automaticallyAdjustsVideoMirroring = false
-                            pc.isVideoMirrored = false
-                        }
-                    }
-                    break
-                case .on:
-                    if let vc = videoOutput.connection(with: AVMediaType.video) {
-                        if vc.isVideoMirroringSupported {
-                            vc.isVideoMirrored = true
-                        }
-                    }
-                    if let pc = self.previewLayer.connection {
-                        if pc.isVideoMirroringSupported {
-                            pc.automaticallyAdjustsVideoMirroring = false
-                            pc.isVideoMirrored = true
-                        }
-                    }
-                    break
-                case .auto:
-                    if let vc = videoOutput.connection(with: AVMediaType.video), let device = self._currentDevice {
-                        if vc.isVideoMirroringSupported {
-                            vc.isVideoMirrored = (device.position == .front)
-                        }
-                    }
-                    if let pc = self.previewLayer.connection {
-                        if pc.isVideoMirroringSupported {
-                            pc.automaticallyAdjustsVideoMirroring = true
-                        }
-                    }
-                    break
-                }
+            guard let _ = self._captureSession,
+                  let videoOutput = self._videoOutput
+            else {
+                return
+            }
+
+            switch newValue {
+            case .off:
+                if let vc = videoOutput.connection(with: AVMediaType.video) {
+                    if vc.isVideoMirroringSupported {
+                        vc.isVideoMirrored = false
+                    }
+                }
+                if let pc = self.previewLayer.connection {
+                    if pc.isVideoMirroringSupported {
+                        pc.automaticallyAdjustsVideoMirroring = false
+                        pc.isVideoMirrored = false
+                    }
+                }
+                break
+            case .on:
+                if let vc = videoOutput.connection(with: AVMediaType.video) {
+                    if vc.isVideoMirroringSupported {
+                        vc.isVideoMirrored = true
+                    }
+                }
+                if let pc = self.previewLayer.connection {
+                    if pc.isVideoMirroringSupported {
+                        pc.automaticallyAdjustsVideoMirroring = false
+                        pc.isVideoMirrored = true
+                    }
+                }
+                break
+            case .auto:
+                if let vc = videoOutput.connection(with: AVMediaType.video), let device = self._currentDevice {
+                    if vc.isVideoMirroringSupported {
+                        vc.isVideoMirrored = (device.position == .front)
+                    }
+                }
+                if let pc = self.previewLayer.connection {
+                    if pc.isVideoMirroringSupported {
+                        pc.automaticallyAdjustsVideoMirroring = true
+                    }
+                }
+                break
             }
         }
     }

    }
    
    internal func exposureEnded() {
        if let device = self._currentDevice {
            guard
                !device.isAdjustingFocus ||
                    !device.isAdjustingExposure
                else {
                    return
            }
            
            let isContinuousAutoExposureEnabled: Bool = (device.exposureMode == .continuousAutoExposure)
            if isContinuousAutoExposureEnabled {
                do {
                    try device.lockForConfiguration()
                    
                    device.isSubjectAreaChangeMonitoringEnabled = true
                    
                    device.unlockForConfiguration()
                }
                catch {
                    print("NextLevel, focus ending failed to lock device for configuration")
                }
            }
            
            DispatchQueue.main.async {
                self.deviceDelegate?.nextLevelDidChangeExposure(self)
            }
        }
    }
    

            return .locked
        }
        set {
            guard let device: AVCaptureDevice = self._currentDevice,
                device.exposureMode != newValue,
                device.isExposureModeSupported(newValue)
                else {
                    return
            }
            
            do {
                try device.lockForConfiguration()
                
                device.exposureMode = newValue
                self.adjustWhiteBalanceForExposureMode(exposureMode: newValue)
                
                device.unlockForConfiguration()
            }
            catch {
                print("NextLevel, exposureMode failed to lock device for configuration")
            }
        }
    }
