the new version is probably what you wanted all along, but notice that the old (L111) and new (R111) lines mean different things... rewriting the new line to use the same syntax as the old, you have

    new_vnic['index'] = next_avail_vnic['index'] unless vnic['index']
vs

    new_vnic['index'] = next_avail_vnic['index'] unless new_vnic['index']