complete rewrite