re-write to separate tables