rewriting framework from scratch