mle function corrected