add a bit of error handling