fixing problem with detach order