move table extracting code into its own module