cleaned up build_tables