fix random thread safe bug