fixed threading problem