refactored threadpool to task