refactor of network task to be fully outside main thread