fixed the bug that references an object after it was destroyed.

I didn't notice this when fixing the problem of commit: dbb9429e.