Finalized perturbation code