It is possible to utilize considerable amounts of demand flexibility in district heating grids? With an extended system boundary that includes buildings, district heating grids, and connection to electricity grids, a co-optimization can be performed that creates great economic value for the economy as well as the environment.