MADS: Reduce the scope of a variable in Resource