change num_threads to function parameters