added multithreading capability