fix primary_key function