             completion(self.accessDeniedError())
         }
     }
-
+    
     func stop(completion: (() -> Void)?) {
         dispatch_async(captureQueue) {
             if self.session.running {

                }
                self.cameraDevice.unlockForConfiguration()
            }

            self.session.startRunning()

            dispatch_async(dispatch_get_main_queue()) {
                completion(error)
            }
        }
    }

    private func cameraDeviceWithPosition(position: AVCaptureDevicePosition) -> AVCaptureDevice? {
        let availableCameraDevices = AVCaptureDevice.devicesWithMediaType(AVMediaTypeVideo)
        for device in availableCameraDevices as! [AVCaptureDevice] {

                // self.delegate?.cameraManager(self, didError: error)
                NSLog("failed to create capture device input")
            }
            
            
            self.stillImageOutput = AVCaptureStillImageOutput()
            self.stillImageOutput?.outputSettings = [
                AVVideoCodecKey  : AVVideoCodecJPEG,
                AVVideoQualityKey: 0.9
            ]
            
            if self.session.canAddOutput(self.stillImageOutput) {
                self.session.addOutput(self.stillImageOutput)
            }
            
            if self.cameraDevice.isFocusModeSupported(.ContinuousAutoFocus) {
                var configLockError: NSError?
                self.cameraDevice.lockForConfiguration(&configLockError)
