Added an error callback function