added option to run single thread or separate