Added multithreading capabilities