needs rewriting the gamma likelihood calculation