added code to multithreading