re-factor tables