made it multi-threaded