Added an option to set thread count