learn and distance functions implemented