Better ancestor check