Added multithreading capability