rewrite the code