refactoring LM and adding stats to it