Introduced a distance Factory