                 device.unlockForConfiguration()
             } catch _ {}
         }
-        
+
         let outputSettings = [AVVideoCodecKey: AVVideoCodecJPEG]
-        
+
         do {
             input = try AVCaptureDeviceInput(device: device)
         } catch let error as NSError {

            print("Error: \(error.localizedDescription)")
            return
        }
        
        if session.canAddInput(input) {
            session.addInput(input)
        }
        
        imageOutput = AVCaptureStillImageOutput()
        imageOutput.outputSettings = outputSettings
        
        session.addOutput(imageOutput)
        
        preview = AVCaptureVideoPreviewLayer(session: session)
        preview.videoGravity = AVLayerVideoGravityResizeAspectFill

    public var currentPosition = CameraGlobals.shared.defaultCameraPosition
    
    public func startSession() {
        session = AVCaptureSession()
        session.sessionPreset = AVCaptureSessionPresetPhoto

        device = cameraWithPosition(position: currentPosition)
        if let device = device , device.hasFlash {
            do {
