Adding code to reconnect