distance calculated function added