added back the maxdate function