add rewrite_module and doctest