refactoring tables