Improved likelihood function