Minor improvement to the ancestors method