Added disconnection handling