Added connection error handling