fix the date counting bug