Added function to calculate ATD