Fixed a detaching bug