clever way to handle connection timeout