fixed the check for primary keys