         }
     }
     
-    private func createPreview() {
+    private func createSession() {
         session = AVCaptureSession()
         session.sessionPreset = AVCaptureSessionPresetHigh
-        
+        dispatch_async(dispatch_get_main_queue()) {
+            self.createPreview()
+        }
+    }
+    
+    private func createPreview() {
         device = cameraWithPosition(currentPosition)
         
         let outputSettings = [AVVideoCodecKey:AVVideoCodecJPEG]

    public var currentPosition = AVCaptureDevicePosition.Back
    
    public func startSession() {
        createPreview()
        
        dispatch_async(cameraQueue) {
            self.session.startRunning()
        }
    }
    

            session.commitConfiguration()
        }
    }
}
