move table stuff to separate file