Adapted the parse_lm