added element conditional

added stuff to prevent errors if the element is not present