added number of threads option