             sourceCampaign: campaign.name
 
           referral.save (err) ->
-            return callback err if err
+            return callback err  if err
             queue.next()
         ->
           source.addReferrer referral, (err)->
-            return callback err if err
+            if err
+              referral.remove()
+              return callback err
             queue.next()
         ->
           target.addReferred referral, (err)->
-            return callback err if err
-            console.info "referal saved successfully for #{target.profile.nickname} from #{source.profile.nickname}"
+            if err
+              referral.remove()
+              return callback err
+            console.info "referal saved for #{target.profile.nickname} from #{source.profile.nickname}"
             queue.next()
         ->
           campaign.increaseGivenAmountSpace (err)->
-            return console.error "Couldnt decrease the left space" if err
+            console.error "Couldnt decrease the left space", err  if err?
             callback null
       ]
       daisy queue
 
+
+    JReferralCampaign = require "./campaign"
+
     JUser.on 'EmailConfirmed', (user)->
-      return console.log "User is not defined in event" unless user
+
+      unless user?
+        return console.warn "User is not defined in '#{EmailConfirmed}' event"
 
       me       = null
       referrer = null
       campaign = null
+
       queue = [
         ->
-          JReferralCampaign = require "./campaign"
-          JReferralCampaign.isCampaignValid (err, { isValid, campaign: campaign_ })->
-            return console.error err if err
-            return  unless isValid
-            campaign = campaign_
-            queue.next()
-        ->
+
+          JReferralCampaign.isCampaignValid (err, res)->
+            return console.error err  if err
+            return  unless res.isValid
+
+            campaign = res.campaign
+            queue.next()
+
+        ->
+
           user.fetchOwnAccount (err, myAccount)->
-            return console.error err if err
+            return console.error err  if err
             # if account not fonud then do nothing and return
-            return console.error "Account couldnt found" unless myAccount
+            return console.error "Account couldn't found" unless myAccount
             me = myAccount
             queue.next()
-        ->
-          referrerUsername = me.referrerUsername
-          return console.info "User doesn't have any referrer" unless referrerUsername
-
-          return console.info "User already get the referrer" if me.referralUsed
+
+        ->
+
+          unless referrerUsername = me.referrerUsername
+            return console.info "User doesn't have any referrer"
+
+          if me.referralUsed
+            return console.info "User already get the referrer"
+
           # get referrer
-          JAccount.one {'profile.nickname': referrerUsername }, (err, referrer_)->
-            # if error occurred than do nothing and return
-            return console.error "Error while fetching referrer", err if err
-            # if referrer not fonud then do nothing and return
-            return console.error "Referrer couldnt found" if not referrer_
-            referrer = referrer_
-            queue.next()
-        ->
+          JAccount.one {'profile.nickname': referrerUsername }, (err, referrer)->
+
+            if err
+              # if error occurred than do nothing and return
+              return console.error "Error while fetching referrer", err
+
+            unless referrer
+              # if referrer not fonud then do nothing and return
+              return console.error "Referrer couldnt found"
+
+            queue.next()
+
+        ->
+
           me.update $set: "referralUsed": yes, (err)->
             return console.error err if err
             queue.next()
-        ->
+
+        ->
+
           persistReferrals campaign, referrer, me, (err)->
             return console.error err if err
             queue.next()
-        ->
+
+        ->
+
           persistReferrals campaign, me, referrer, (err)->
             return console.error err if err
             queue.next()
+
       ]
+
       daisy queue
-
-



  @addExtraReferral: secure (client, options, callback)->
    {delegate} = client.connection
    unless delegate.can 'administer accounts'
      return callback {message: "You can not add extra referral to users"}

          return callback err if err
          return callback null, referral


  do ->

    JAccount.on 'AccountRegistered', (me, referrerCode)->

      return console.error "Account is not defined in event"  unless me
      return  unless referrerCode

      {nickname} = me.profile
      if nickname is referrerCode
        return console.error "User (#{nickname}) tried to refer themself."

      me.update $set: referrerUsername: referrerCode, (err)->

        unless err
          console.log "referal saved for #{nickname} from #{referrerCode}"


    persistReferrals = (campaign, source, target, callback)->

      referral = null
      queue = [
        ->
