     # copy the fields
     newmailboxIDs = {}
     newmailboxIDs[boxid] = uid for boxid, uid of @mailboxIDs
-    newflags = (flag for flag in @flags)
 
     # scan the patch and change the fields
     boxOps = {addTo: [], removeFrom: []}

                # step 2a - remove flags
                (cb) ->
                    if flagsOps.remove.length
                        imap.delFlags firstuid, flagsOps.remove, cb
                    else
                        cb null
                # step 2b - add flags
                (cb) ->
                    if flagsOps.add.length
                        imap.addFlags firstuid, flagsOps.add, cb
                    else
                        cb null

            flagsOps.add.push operation.value

        else if operation.op is 'remove'
            flagsOps.remove.push @flags[index]

        else if operation.op is 'replace'
            flagsOps.remove.push @flags[index]
