fixed bug in getting ancestors