working on maximum likelihood threshold