removed redundant code
created table_names and union_names helpers