fixed bug that occured when reconnecting multiple times