Added more error-handling