optimising rewrite!