Added checking for valid date input