Modified attach_device