rewriting tables