download in thread and separate code