adapted state_machine for retry batches