adding basic error handling