add offline detection for API calls