Updated error-handling