Added back in error handling code