switch to logsumexp