Move code into AsyncTask