Fix while. Calculate mean for Energy.