Added error handling support