fix bug with detecting invalid dates