Adding basic error handling