Added exception handling if an element does not exist