added pair tables and joins