refactored the files, added handle for energy function, added aux energy function