better connection error handling