Code to optimize with a backup