flipped out the energy function into its own module