fixing reference to subset instead of lastDate variable.