Added internet check at the beginning