Fix to check # of detached node before executing detach-command