Added more connection error handling