fix up error handling so we don't crash