implemented multithreading