rewrite by js