improved primary key validation. Now works regardless of the order