implement lm score calculation