Adding lottery and invalidateThread functions