fix bug where a new element is given the ID of its parent