Fixed bug in date comparison