added handling for connection problems