change the way of checking whether network is connected