fix bug with primary key