smarter reconnection handling