made simulation multithreaded