finished table_exists method