made it multithreaded