Attempted workaround to can't modify immutable index error