A working version of the likelihood code