Add check for invalid date format