Almost done on htrewrite