Closed #11: Add rewrite function