rough outline of new rewriting