js rewrite