Fixed bug concerning date comparison