rewrite all code