added reconnect functionality