The working version with IntentService