 
   }
 
-  func updateMLKit() {
-    ///////////////////////////
-    // Get Camera Image as RGB
-
+  private func createVisionImage() -> VisionImage? {
     guard let pixbuff : CVPixelBuffer? = sceneView.session.currentFrame?.capturedImage else {
-      return
+      return nil
     }
     let ciImage = CIImage(cvPixelBuffer: pixbuff!)
 
     let context = CIContext.init(options: nil)
 
     guard let cgImage = context.createCGImage(ciImage, from: ciImage.extent) else {
-      return
+      return nil
     }
     let rotatedImage =
       UIImage.init(cgImage: cgImage, scale: 1.0, orientation: .right)
     guard let rotatedCGImage = rotatedImage.cgImage else {
-      return
+      return nil
     }
     let mirroredImage = UIImage.init(
       cgImage: rotatedCGImage, scale: 1.0, orientation: .leftMirrored)
 
-
-    let visionImage = VisionImage.init(image: mirroredImage)
+    return VisionImage.init(image: mirroredImage)
+  }
+
+  func updateMLKit() {
+    guard let visionImage = createVisionImage() else { return }
     let group = DispatchGroup()
     let options = VisionLabelDetectorOptions.init(confidenceThreshold: 0.7)
     group.enter()

          "\(feature.label) \(String(format:"- %.2f", feature.confidence))" }
        .joined(separator: "\n")



      DispatchQueue.main.async {
        // Display Debug Text on screen
        var debugText:String = ""

        anchors.updateValue(latestPrediction, forKey: cloudAnchor.identifier)
      }

      addLabel(latestPrediction, withTransform: transform, isNew: true)
    }
  }

  func addLabel(_ label: String, withTransform transform: matrix_float4x4, isNew: Bool) {
    let worldCoord : SCNVector3 = SCNVector3Make(transform.columns.3.x, transform.columns.3.y, transform.columns.3.z)

    // Create 3D Text
    let node : SCNNode = createNewBubbleParentNode(label, isNew: isNew)
    sceneView.scene.rootNode.addChildNode(node)
    node.position = worldCoord
  }

  func createNewBubbleParentNode(_ text: String, isNew: Bool) -> SCNNode {
    // Warning: Creating 3D Text is susceptible to crashing. To reduce chances of crashing; reduce number of polygons, letters, smoothness, etc.

    // TEXT BILLBOARD CONSTRAINT
