rewrite for fun