added multithreading capabilities