issues with primary key (also added some logging)