Fixed error in checking network connection