fix a bug concerning undefined dates