improved hessian implementation, now potential is called once for each pair