fixed bug in detach()

incorrect variable names