Implemented methods to attach and detach the object.