fixed bugs
multithreaded