improve error handling invalid dates