replace the unitary time evolution of the system with a Lindblad type master equation as $$\label{Lindblad}
 \dot{\rho}(t)= -i[H,\rho(t)]+\gamma\sum_{k=1}^{N}\sum_{\mu=1}^2(L^\mu_{k}\rho(t)L^{\mu \dagger}_{k} - \frac{1}{2} \{ L^\mu_{k}L^{\mu \dagger}_{k},\rho(t) \} )$$ where $L^1_{k}=\sigma^+_k$ and $L^2_{k}=\sigma^-_k$ are the Lindblad operators which add and subtract spin excitations into the system respectively and the coefficient $\gamma$ represents the coupling with the environment. By tracing out all spins but the last one can compute the fidelity which peaks at $t=t_{opt}$ no matter how strong is the coupling $\gamma$. In Fig. \[fig5\](b) we plot $F_{max}$ as a function of $\gamma$ for chain of length $N=10$ when the first spin is projected to $|+\ra=(|\uparrow\ra+|\downarrow\ra)/\sqrt{2}$. As it is clear, the fidelity goes down by increasing $\gamma$ and stays above $0.75$ even for $\gamma\simeq0.1J$.

Another imperfection is randomness in the coupling of the Hamiltonian as making a uniform chain might be very challenging in some physical realizations. This means that in the Hamiltonian of Eq. (\[H\]) we have $J_{k}=J(1+\delta_{k})$, where, $\delta_{k}$ is a dimensionless random number with a uniform distribution in the interval $[-\epsilon,\epsilon]$. In fact, $\epsilon$ determines the strength of randomness in the couplings. We fix the optimal time to be $t_{opt}$, determined from the uniform chain (i.e. $\epsilon=0$), as the real 