restructure tables