rewrite some code