fixed bug in reconnection