Updated with more ability to reconnect