Added check for internet connection