   }
 
   func timestamp() -> Double {
-    let now = DispatchTime.now()
-    let nanoTime = now.uptimeNanoseconds - startTime.uptimeNanoseconds
-    let elapsed = Double(nanoTime / 100) / 1_000_000.0
+    let now = Date().timeIntervalSinceReferenceDate
+    let elapsed = Double(round((now - startTime) * 1_000_000) / 1_000_000)
     return elapsed
   }
 

   *************************************************************************************/
  func startVideo(id:String) {
    if videoCapture == nil {
      deleteVideo()
      videoCapture = ASScreenRecorder()
      videoCapture!.videoURL = videoUrl
      videoCapture!.bitrate = 8000000
      videoCapture!.scale = 1.0
      videoCapture!.startRecording()
      sendMessage(id:id, message:"OK")
    } else {
      sendMessage(id:id, message:"ERROR")
    }
  }
  
  func stopVideo(id:String) {
    if videoCapture != nil {
      videoCapture!.stopRecording() {
        self.videoCapture = nil

    }
  }
  
  func clientDisconnected() {
    // clean up if we were capturing video and had a browser loaded
    stopVideoTimer()
    if videoCapture != nil {
      videoCapture!.stopRecording() {
        self.videoCapture = nil
        self.deleteVideo()
      }
    }
    closeWebView()
    hasOrange = false
    isActive = false
    title = "iWptBrowser"
  }
  
  /*************************************************************************************
                                  browser operations
   *************************************************************************************/
