Understanding the potential energy flexibility of buildings