added preferences to throw exception if element not found