More robust error-handling