Added error handling structure