 
       JVM.one {hostnameAlias}, (err, vm)=>
         return console.error err  if err or not vm
-        console.log "Old vm found, passing..."
-        JAccount.one {'profile.nickname':username}, (err, account)=>
-          return console.error err  if err or not account
-          console.log "New account found, passing..."
-          vm.update {$set: {hostnameAlias: newHostNameAlias}}, (err)=>
-            return console.error err  if err
-            console.log "VM hostnameAlias updated, passing..."
-            nameFactory = (require 'koding-counter')
-              db          : JVM.getClient()
-              offset      : 0
-              counterName : "koding~#{username}~"
-            nameFactory.next (err, uid)=>
+        # Old vm found
+
+        # Removing old vm domains...
+        JVM.removeRelatedDomains vm, (err)=>
+          if err
+            console.error "Failed to remove old domains for #{hostnameAlias}"
+
+          JAccount.one {'profile.nickname':username}, (err, account)=>
+            return console.error err  if err or not account
+            # New account found
+
+            vm.update {$set: {hostnameAlias: newHostNameAlias}}, (err)=>
               return console.error err  if err
-              console.log "Counter created with #{uid}, passing..."
-              JVM.ensureDomainSettings {
-                type:'user', nickname:username, groupSlug:'koding'
-                account, vm
-              }
+              # VM hostnameAlias updated
+
+              nameFactory = (require 'koding-counter')
+                db          : JVM.getClient()
+                offset      : 0
+                counterName : "koding~#{username}~"
+              nameFactory.next (err, uid)=>
+                return console.error err  if err
+                # Counter created
+
+                JVM.ensureDomainSettings {
+                  type:'user', nickname:username, groupSlug:'koding'
+                  account, vm
+                }
+
+                console.log """Migration completed for
+                               #{hostnameAlias} to #{newHostNameAlias}"""
 
     JGroup.on 'GroupDestroyed', (group)->
       group.fetchVms (err, vms)->

          return callback err, []  if err or not vm
          JVM.fetchDomains {hostnameAlias: vm.hostnameAlias}, callback

  @removeRelatedDomains = (vm)->
    vmInfo = @parseAlias vm.hostnameAlias
    return  unless vmInfo

    # Create same aliases based on vm info
    aliasesToDelete = @createAliases vmInfo


    JDomain = require './domain'
    JDomain.remove selector, (err)->
      callback err
      return console.error "Failed to delete domains:", err  if err

  remove: (callback)->
