Still working on local energy function