       if not vdi?
         return
       for vbd in vdi.$VBDs
-        rVbd = vbd if (get vbd).VM is $scope.VM.id
+        rVbd = vbd if (get vbd)?.VM is $scope.VM?.id
       return rVbd || null
 
     $scope.disconnectVBD = (vdi) ->

            () => this.stop(),
            this.baseTimeOut
          )
          return $scope.refreshStats($scope.VM.id)
          .then () => this._reset()
          .catch (err) =>
            if !this.running || this.attempt >= 2 || $scope.VM.power_state isnt 'Running' || $scope.isVMWorking($scope.VM)

    $window.bytesToSize = bytesToSizeFilter # FIXME dirty workaround to custom a Chart.js tooltip template
    {get} = xoApi

    checkMainObject = ->
      if !$scope.VM
        $state.go('index')
        return false
      else
        return true

    pool = null
    host = null
    vm = null
