Stability of quantum computers to imperfections is of crucial importance for their proper working. Indeed, the power of a quantum computer relies on an interference and entanglement and can be as such very sensitive to perturbations, whether they result from the coupling with the environment or from the faulty algorithm itself. For successful realization of even modest-size quantum computer, understanding sensitivity to the perturbation is very important. As a measure of stability we choose to study fidelity. First, we expand fidelity in terms of correlation functions of a generator of perturbation. Decay of fidelity is related to the integral of a correlation function. Contrary to common intuition, we argue that for "chaotic" quantum systems, where correlation functions decay fast, the fidelity falls exponentially with time. In turn, for "integrable" systems with a non-decaying correlation function, the dependence is Gaussian. Although simple, this novel way of looking at fidelity greatly facilitates understanding of its behavior under perturbation. To demonstrate the above theory we apply it on a Quantum algorithm for discrete Fourier Transformation (QFT) algorithm. For a constant static random matrix perturbation on the whole Hilbert space of a computer, the fidelity falls with the number of qubits as . By a simple change of an algorithm, so that the correlation function decays faster, we change this behavior into . For instance, this would mean improving fidelity in the case of qubits from for plain FFT algorithm to for our improved one.