Fixing threading issue?