change in logic to handle case for an existing records