added option for multithreading