fixed a glitch that came from multithreading.