next_date bug fix