refactor checkForConnectivityInBackground