more robust package detach