fixed the threading issue