fixed logGammaSum, not optimised yet