more robust handling of DOM IDs