Optimize subscope destruction by rewriting as a for loop