Made likelihood calculation more rigorous