fix bug for function AttachTo()