add distance func