Added checking of wifi connection