fix some bugs and modify the energy to preserve length