much better calculation of dates