optimized thread pool version