                 else
                     mailsDone++
                     diff = mailsToGo - mailsDone
-                    importProgress = mailbox.mailsToImport - diff
-                    job.progress importProgress, mailbox.mailsToImport
+                    importProgress = @mailsToImport - diff
+                    job.progress importProgress, @mailsToImport
                     
                     if mailsToGo is mailsDone
                         callback()

                        fetchOne server, mailsToBe, i + 1, mailsToGo, mailsDone
                                       
        else
            server.logout () ->
                if mailsToGo isnt mailsDone
                    msg = 'Could not import all the mail.'
                    server.emit 'error', new Error msg
                callback()

            idInt = parseInt id
            maxId = idInt if idInt > maxId
    
            mailbox.mailsToBe.create remoteId: idInt, (error, mailToBe) =>
                if error
                    server.logout -> server.emit "error", error
                else
                    console.log "#{mailToBe.remoteId} id saved successfully"
                    mailsDone++
        
                    if mailsDone is mailsToGo
                        console.log "Finished saving ids to database"
                        console.log "max id = #{maxId}"
