A function to compute ages