bug fix to reconnection logic