code clean up - energy functions
using function pointer for energy functions