finally fix threading