removed duplicate code by changing perturb