code for improved likelihood
code for improved likelihood