Replace isDetached with a working function