fixed a bug with reconnection