Fixed isConnected being set to true before connection actually happened