rewrite some function