fixed a threading issue