refactoring language model, still not really correct
merged