Fixed threading error