Added buildDates function