some smarter (but not genius) error handling