Added structure for error handling