rewrite functionality