fix to set_params

set_params on Windows will set to last item if index is higher than
#items, error on mac. corrected here.