Fixed threading issue