Fixing 'values not unique' errors