Fixed undefined error when destroying scope PR#2