fixed threading error