You don't need this if-else, if the second argument to `insertBefore` is null it just add the element to the target node. (thus making it the first child)