     { guessNextLabel } = require './computeutils'
 
     guessNextLabel { user, group, label, provider }, (err, label) ->
-      checkPlans { client, provider, change: 'increment' }, (err) ->
+      updateCounter { client, provider, change: 'increment' }, (err) ->
         return callback err  if err?
 
         meta =

getKiteIdOnly = (queryString) ->
  "///////#{queryString.split('/').reverse()[0]}"

checkPlans = (options, callback) ->

  { client, provider, change } = options
  { r: { group, user, account } } = client

  if group.slug is 'koding'

    return callback null  if change is 'decrement'

    { fetchUserPlan, fetchUsage } = require './computeutils'

    fetchUserPlan client, (err, userPlan) ->
      fetchUsage client, { provider }, (err, usage) ->
        return callback err  if err?

        if usage.total >= userPlan.managed
          return callback new KodingError """
            Total limit of #{userPlan.managed}
            managed vm limit has been reached.
          """, 'UsageLimitReached'

        callback null

  else

    ComputeProvider = require './computeprovider'

    options = {
      instanceCount : 1
      instanceOnly  : yes
      details       : { account, provider: 'managed' }
      change        : 'increment'
      group
    }

    ComputeProvider.updateGroupResourceUsage options, (err) ->
      callback err


module.exports = class Managed extends ProviderInterface

        machine.destroy client, (err) ->
          return callback err  if err

          updateCounter {
            client, provider: @providerSlug, change: 'decrement'
          }, (err) -> callback null

