found a bug in detach