fix atomic operation for threadding