Fixed bug with custom primary key