implementing detach