fixed .val(values)

loop deleting existing ranges now starts deletion from the last range, fixing cases where amount of new ranges is shorter than amount of existing ranges.