adding calculation of ancestors