update documentation and distance function