fixing threading error