Fixing fatal error if element doesn't exist

Fixing fatal error if element doesn't exist