fixed calculating log likelihood bug, refactored