Fixed bug when detaching head