update to make the sort variable work better