Added a check for an existing id so as not to ruin existing id element