 
     return callback null  if group.slug is 'koding'
 
-    planConfig   = helpers.getPlanConfig group
-
-    maxAllowed   = MAX_INT
-    if planConfig.plan
-      plan       = teamutils.getPlanData planConfig
+    planConfig = helpers.getPlanConfig group
+
+    teamutils.getPlanData planConfig, (err, plan) =>
+
+      return callback err  if err
+
       maxAllowed = plan.member ? MAX_INT
 
-    JCounter = require '../counter'
-    JCounter[change]
-      namespace : group.getAt 'slug'
-      type      : @COUNTER_TYPE.stacks
-      max       : maxAllowed
-      min       : 0
-    , (err) ->
-      # no worries about `decrement` errors
-      # since 0 is already defined as min ~ GG
-      callback if change is 'increment' then err else null
+      JCounter = require '../counter'
+      JCounter[change]
+        namespace : group.getAt 'slug'
+        type      : @COUNTER_TYPE.stacks
+        max       : maxAllowed
+        min       : 0
+      , (err) ->
+        # no worries about `decrement` errors
+        # since 0 is already defined as min ~ GG
+        callback if change is 'increment' then err else null
 
 
   @updateGroupInstanceUsage = (options, callback) ->


  # Just takes the plan config and the stack template content generates rules
  # based on th plan then verifies the content based on the rules generated
  @validateTemplateContent = (content, planConfig) ->

    rules = teamutils.generateConstraints planConfig

    try
      template = JSON.parse content
    catch
      return new KodingError 'Template is not valid'

    { passed, results } = konstraints template, rules, {}
    return new KodingError results.last[1]  unless passed

    return null


  # Template checker, this will fetch the stack template from given id,

    # A stack template without machines in it? ~ GG
    return callback null  if group.slug is 'koding' or amount is 0

    planConfig   = helpers.getPlanConfig group
    maxAllowed   = MAX_INT

    teamutils.getPlanData planConfig, (err, plan) =>

      return callback err  if err

      maxAllowed = plan.maxInstance  if plan

      JCounter = require '../counter'
      JCounter[change]
        namespace : group.getAt 'slug'
        amount    : amount
        type      : @COUNTER_TYPE.instances
        max       : maxAllowed
        min       : 0
      , (err) ->
        # no worries about `decrement` errors
        # since 0 is already defined as min ~ GG
        callback if change is 'increment' then err else null


  @updateGroupResourceUsage = (options, callback) ->
