primary key logic fix