extract a new public addObject() method out of replaceText()