fix bug in next date calc