# KERI (with re-processing) out-of-order evenst state re-calculation
###### tags: `out_of_order`
```plantuml
@startuml
start
:new message [M] processing;
if (Dip or Drt) then (true)
if (validate_seal()) then (false)
if (Error::EventOutOfOrder) then (true)
:add to **out of order** table;
else (false)
endif
:return Err;
stop
else (true)
endif
else (false)
endif
if (**self.apply_to_state([M]))**) then (Ok)
:verify event signatures;
:add to **kel finalized events** table;
partition "Out of order re-calculation" {
:let **recalculated_state**/
while (**out of order event** [OOE] present in the DB) then (yes)
if (**apply_to_state([OOE])** and **verif([OOE])**) then (Ok)
:**recalulated_state** = **compute_state()** recalculation}
:add it to **kel finalized events** table;
:remove it from **outoforder** table;
else
:ignore;
endif
endwhile(no)
if (**recalculated_state** != IdentifierStat::default()) then (true)
:return Ok(relalcuulated_state);
else (false)
:return Ok(new_state);
endif
stop
}
else (Error)
:match Error;
split
:Error::EventOutOfOrder
-> add to **outoforder** table;
split again
:Error::NotEnoughSigs
-> add to **partialy signed** table;
split again
:Error::EventDuplicate
-> add to **duplicious events** table;
endsplit
:return Error;
stop
@enduml
```