rewrite to saner constructs