rewrite code generations by js