fixed detachment bugs