adding detachment functionality