Fixed bug if energy is None