added multithreading