fixed rules to perform UPSERTs