Added validity check for years