Adding error handling functions.