remove some work from main thread.

move some work from main thread to new thread