Decouple DOM from model
Improve algorithm?