engine.js rewrite