Fix conditions for maxDate detection