a lot of rewriting