added max_likelihood n>0 check