Moved the code previously contained in the finishedCreatingElement function into the setElementParent function.