                                 mailsDone++
                                 job.progress mailsDone, results.length
 
-                                if mailsToGo is mailsDone
+                                if mailsDone is results.length
                                     callback()
                                 else
                                     fetchOne(server, i + 1, results, mailsDone)
 
         else
             server.logout ->
-                if mailsToGo isnt mailsDone
+                if mailsDone isnt results.length
                     msg = "Could not import all the mail. Retry"
                     server.emit "error", new Error(msg)
 

                        return callback(err) if err

                        if typeof mailToBe is "string"
                            callback mail
                        else
                            mailToBe.destroy (error) ->
                                return callback(err) if err
                                callback mail

        message.on "data", (data) ->
            # on data, we feed the parser

                            activated: true
                            importing: true

                        @updateAttributes data, (err) =>
                            server.logout () =>
                                console.log "[#{@name}] All mail ids collected"
                                callback err
                    else
                        fetchOne server, results, i + 1, mailsDone, mailsToGo, maxId
