bug fix when dates are invalid