adds basic error handling