Wrote perturb function