Attempt at calculating logZ