rewrite a bit