Made add_period_to_date more efficient