add nicer error handling