added potential energy calculating