added automatic reconnect