added element conditional

added stuff to prevent errors if the element is not present
should be element, not global
Merge pull request #6 from GloverDonovan/patch-5

added element conditional