rewrite the generated code using javascript only