Closed #11: Add rewrite function

Add rewrite function