changed to upsert handling ot database level.