Fix threading error