changing the cores variable to num_threads